<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div>我是div</div>
  <span>我是span</span>

  <script>
    var div = document.querySelector('div');
    // 1. nextSibling 下一个兄弟节点，包含元素节点或者文本节点等等
    console.log(div.nextSibling);
    console.log(div.previousSibling);

    // 2. nextElementSibling 得到下一个兄弟元素节点，不过有兼容性问题
    console.log(div.nextElementSibling);
    console.log(div.previousElementSibling); // 没有就会返回 null
  </script>
</body>

</html>